package com.myspring.web.route.aop;

import com.myspring.web.route.ChannelService;
import com.myspring.web.route.domain.LoanRequest;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.HashMap;

/**
 * 参考资料：
 *  spring boot 拦截器 或 Spring AOP 方式记录请求日志：https://my.oschina.net/gmd/blog/704372
 *  拦截器解析requestbody：http://stackoverflow.com/questions/10457963/spring-rest-service-retrieving-json-from-request
 */
@Aspect
@Component
public class MatchAspect {

//    @Resource
    private HashMap<String, ChannelService> channelServiceHashMap;

    @Pointcut("execution(public * com.myspring.web.route..*.loan*(..))")
    public void routeService() {}

    @Before("routeService()")
    public void doBefore(JoinPoint joinPoint) {
        Object[] args = joinPoint.getArgs();
        LoanRequest loanRequest = (LoanRequest) args[0];



    }


    public void buildProcessor(LoanRequest loanRequest) {
        String bankCode = loanRequest.getBankCode();
        String modeType = "123";
        //编号+mode作为key
        String key = bankCode + modeType;

        channelServiceHashMap.get(key);
    }
}
